<template>
<h1 id="custom-h1">hello</h1>
</template>

<script>
import { ref, onMounted, onBeforeMount } from 'vue'
export default {
  name: 'App',
  setup() {

    onBeforeMount(() => {
      console.log(document.querySelector('#custom-h1')) // null
    })

    onMounted(() => {
      console.log(document.querySelector('#custom-h1')) // <h1 id="custom-h1">hello</h1>
    })
  }
}
</script>
